<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./PrincipalTemplate.xhtml">

            <ui:define name="top">
                top
            </ui:define>

            <ui:define name="left">
                left
            </ui:define>

            <ui:define name="content">
                <f:view>
                    <h:form>
                        <h1><h:outputText value="Create Sale"/></h1>
                        <p:panelGrid columns="2">
                            <h:outputLabel value="Idsale:" for="idsale" />
                            <h:inputText id="idsale" value="#{salesBean.sale.idsale}" title="Idsale" required="true" requiredMessage="The Idsale field is required."/>
                            <h:outputLabel value="Folio:" for="folio" />
                            <h:inputText id="folio" value="#{salesBean.sale.folio}" title="Folio" required="true" requiredMessage="The Folio field is required."/>
                            <h:outputLabel value="Total:" for="total" />
                            <h:inputText id="total" value="#{salesBean.sale.total}" title="Total" required="true" requiredMessage="The Total field is required."/>
                            <h:outputLabel value="IdsaleDetail:" for="idsaleDetail" />
                            <p:panelGrid columns="3">
                            <h:selectOneMenu id="idsaleDetail" value="#{salesBean.selectedSaleDetail}" title="IdsaleDetail" required="true" requiredMessage="The IdsaleDetail field is required.">
                                <!-- TODO: update below reference to list of available items-->
                                <f:selectItems value="#{saleDetailsBean.listSaleDetail}" var="item" itemLabel="#{item.idsailDetail}" itemValue="#{item.id}"/>
                            </h:selectOneMenu>
                                <p:commandButton value="Add" actionListener="#{salesBean.agregarDetalle}"/>
                            </p:panelGrid>
                            <p:commandButton value="Register" action="#{salesBean.processAction()}" ajax="false"/>
                            <p:commandButton value="Cancel" immediate="true" action="SalesList" ajax="false"/>
                        </p:panelGrid>
                    </h:form>
                </f:view>
            </ui:define>
        </ui:composition>

    </body>
</html>
